/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ie.deloitte.cvapp.service;

import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.List;

import ie.deloitte.cvapp.dataaccess.ExperienceDAO;
import ie.deloitte.cvapp.domain.Employee;
import ie.deloitte.cvapp.domain.Experience;
import ie.deloitte.cvapp.form.ExperienceBeanForm;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *
 * @author damorales
 */
@Service("experienceService")
public class ExperienceServiceImpl implements ExperienceService {

    @Autowired
    private ExperienceDAO experienceDAO;

    public void saveExperience(ExperienceBeanForm eb) {


    	Experience e = new Experience();
        //SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
        
    	String getidExperience = eb.getidExperience();
    	String idEmployee = eb.getIdEmployee();

    	e.setidExperience(Integer.valueOf(getidExperience));
		e.setEmployee_idEmployee(Integer.valueOf(idEmployee));
        e.setCompanyname(eb.getCompanyname());
        e.setDescription(eb.getDescription());
        //e.setperiodStart(dateFormat.parse(periodStart));
        //e.setperiodFinish(dateFormat.parse(periodFinish));
        e.setperiodStart(eb.getPeriodStart());
        e.setperiodFinish(eb.getPeriodFinish());
        e.setprojectname(eb.getprojectname());
        e.setRole(eb.getRole());
        e.setResponsibilities(eb.getResponsibilities());
        
        
        experienceDAO.save(e);
        
    }
    
    public List<Experience> getExperienceById(String idStr) {
		
		return this.experienceDAO.getById(idStr);
	}

	public ExperienceBeanForm findExperience(String experienceId) {
		// TODO Auto-generated method stub
		return null;
	}
	
	public List<Experience> getAllExperiences() {
	     return this.experienceDAO.getAll();
	    }
    
    
}